﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;
using Taobao.Manger;

namespace Taobao
{
    public class MvcApplication : System.Web.HttpApplication
    {
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            //方法1. 自定义事件注册 利用.net MessageQueue 实现 错误日志并发时 放到消息队列中
            ScanQueueClass.RegisterUrlQueue();
            //错误日志
            ScanQueueClass.RegisterExceptionLogQueue();
        }

        protected void Application_EndRequest()
        {
            // var statusCode = Context.Response.StatusCode;
            // var routingData = Context.Request.RequestContext.RouteData;
            // //if (statusCode == 404 || statusCode == 500)
            // //{
            //     Response.Clear();
            //     //   var area = DataHelper.ConvertTo(routingData.DataTokens["area"], string.Empty);
            //     //if (area == "Admin")
            //     //{
            //     Response.RedirectToRoute("Default", new { controller = "Error", action = "Index", id = UrlParameter.Optional });
            //     //}
            //     //else
            //     //{
            //     //    Response.RedirectToRoute("Default", new { controller = "Error", action = "NotFound", id = UrlParameter.Optional });
            //     //}
            //// }
        }
    }
}
